#! /bin/sh

USER=admin
PASSWORD=admin

HOSTNAME=localhost
PORT=8080
CONTEXT=template/ws/person

echo "Please type id"
read ID
echo "Please type login"
read LOGIN
echo "Please type email"
read EMAIL
echo "Please type title"
read TITLE
echo "Please type name"
read NAME
echo "Please type firstname"
read FIRSTNAME
echo "Please type password"
read PASSWD

if [ "x$ID" = "x" ]; then
    ID="1"
fi
if [ "x$LOGIN" = "x" ]; then
    LOGIN="mic"
fi
if [ "x$EMAIL" = "x" ]; then
    EMAIL="holst.mic@gmail.com"
fi
if [ "x$TITLE" = "x" ]; then
    TITLE="1"
fi
if [ "x$NAME" = "x" ]; then
    NAME="1"
fi
if [ "x$FIRSTNAME" = "x" ]; then
    FIRSTNAME="1"
fi
if [ "x$PASSWD" = "x" ]; then
    PASSWD="mic"
fi

JSON=`cat <<EOF
	{ 
			"id":"$ID",
			"login":"$LOGIN",
			"email":"$EMAIL",
			"title":"$TITLE",
			"name":"$NAME",
			"firstName":"$FIRSTNAME",
			"password":"$PASSWD"}
    }
EOF`


# use -u for authentication if required!
# -u "$USER:$PASSWORD" \

curl -X PUT \
	-d "$JSON" \
        -H "Content-Type: application/json" \
	-H "Accept: application/json" \
	"http://$HOSTNAME:$PORT/$CONTEXT/update"

echo

# EOF
